package heterogeneousContainers;

/**
 * Created with IntelliJ IDEA.
 * User: Georgiana.Scarlat
 * Date: 8/30/12
 * Time: 2:48 PM
 *
 */
public class Column<T> {
    private Class<T> columnClass;
    private String columnName;

    public Column(Class<T> columnClass, String columnName) {
        this.columnClass = columnClass;
        this.columnName = columnName;
    }


    public T cast(Object obj){
        return columnClass.cast(obj);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Column column = (Column) o;

        return !(columnClass != null ? !columnClass.equals(column.columnClass) : column.columnClass != null) && !(columnName != null ? !columnName.equals(column.columnName) : column.columnName != null);

    }

    @Override
    public int hashCode() {
        int result = columnClass != null ? columnClass.hashCode() : 0;
        result = 31 * result + (columnName != null ? columnName.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "Column{" +
                "columnName='" + columnName + '\'' +
                '}';
    }


}
